package com.ytjj.quartz.utils;

import com.tencent.ads.ApiContextConfig;
import com.tencent.ads.TencentAds;
import com.tencent.ads.model.OauthTokenResponseData;

/**
 *
 * @version 1.0
 *
 */
public class Example {

    private static Long clientId = 1111245968L; // 修改为你的clientId
    private static String clientSecret = "DvHz1hnSdHVapeMu"; // 修改为你的clientSecret
    private static String grantType = "authorization_code";
    private static String authorizationCode = "a6ed422d0baa42977eeaec68ba1e5b53"; // 修改为你获取到的AUTHORIZATION CODE
    private static String redirectUri = "https://api.quanminyanxuan.com/api/mall/yyb_response"; // 修改为你的回调地址

    public static void main(String[] args) {
        TencentAds tencentAds = TencentAds.getInstance();
        tencentAds.init(new ApiContextConfig());

        try {
            OauthTokenResponseData responseData = tencentAds.oauth()
                    .oauthToken(clientId, clientSecret, grantType, authorizationCode, null, redirectUri);
            if (responseData != null) {
                String accessToken = responseData.getAccessToken();
                System.out.println(accessToken);
                tencentAds.setAccessToken(accessToken);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
